// 
// Bachelor of Software Engineering
// Media Design School
// Auckland
// New Zealand
//
// (c) 2005 - 2014 Media Design School
//
// File Name	: PlayingCard.cpp
// Desrciption	: CPlayingCard implementation file.
// Author(s)	: Hayden Asplet.
// Mail			: hayden.asplet@mediadesignschool.com
//

// PCH
#include "SolitaireStd.h"

// Library Includes

// This include
#include "PlayingCard.h"

// Local Includes

CPlayingCard::CPlayingCard()
	:m_eValue(keAce),
	m_eSuit(keHearts),
	m_bIsFaceUp(0)
{

}

CPlayingCard::CPlayingCard(ECardValue _eValue, ECardSuit _eSuit, bool _bIsFaceUp)
	:m_eValue(_eValue),
	m_eSuit(_eSuit),
	m_bIsFaceUp(_bIsFaceUp)
{

}

CPlayingCard::CPlayingCard(ECardValue _eValue, ECardSuit _eSuit, const CPoint& _krPosition, bool _bIsFaceUp)
	:m_eValue(_eValue),
	m_eSuit(_eSuit),
	m_position(_krPosition),
	m_bIsFaceUp(_bIsFaceUp)
{

}

CPlayingCard::~CPlayingCard()
{

}


void CPlayingCard::Flip()
{
	// Negate m_bIsFaceUp.
	m_bIsFaceUp = !m_bIsFaceUp;
}

bool CPlayingCard::operator==(const CPlayingCard& _krCard) const
// Only compares suit and value.
{
	return m_eValue== _krCard.GetValue() &&
		   m_eSuit == _krCard.GetSuit();
}

bool CPlayingCard::operator!=(const CPlayingCard& _krCard) const
{
	return !(*this == _krCard);
}

void CPlayingCard::SetPosition(const CPoint& _krPosition)
{
	m_position = _krPosition;
}

void CPlayingCard::SetPosition(const int _kiX, const int _kiY)
{
	m_position.m_iX = _kiX;
	m_position.m_iY = _kiY;
}

void CPlayingCard::SetValue(const ECardValue& _kreValue)
{
	m_eValue = _kreValue;
}

void CPlayingCard::SetSuit(const ECardSuit& _kreSuit)
{
	m_eSuit = _kreSuit;
}

void CPlayingCard::SetIsFaceUp(bool _bIsFaceUp)
{
	m_bIsFaceUp = _bIsFaceUp;
}

bool CPlayingCard::IsRed() const
{
	return m_eSuit == keHearts || m_eSuit == keDiamonds;
}

bool CPlayingCard::IsBlack() const
{
	return m_eSuit == keSpades || m_eSuit == keClubs;
}

CRect CPlayingCard::GetRect() const
{
	return CRect(m_position.m_iX, m_position.m_iY, g_kiCARD_WIDTH, g_kiCARD_HEIGHT);
}

const CPoint& CPlayingCard::GetPosition() const
{
	return m_position;
}

ECardValue CPlayingCard::GetValue() const
{
	return m_eValue;
}

ECardSuit CPlayingCard::GetSuit() const
{
	return m_eSuit;
}

char* CPlayingCard::GetSuitString() const
{
	switch(m_eSuit)
	{
		case keHearts:
			return "Hearts";
		case keSpades:
			return "Spades";
		case keDiamonds:
			return "Diamonds";
		case keClubs:
			return "Clubs";
		default:
			return "None";
	}
}

bool CPlayingCard::IsFaceUp() const
{
	return m_bIsFaceUp;
}

bool CPlayingCard::IsFaceDown() const
{
	return !m_bIsFaceUp;
}